Skip to content

fix: match host names case-insensitively and static prefixes on escaped paths - #270

Merged
umputun merged 2 commits into
masterfrom
fix-host-case-escaped-prefix
Oct 31, 2026
Merged

umputun merged 2 commits into
masterfrom
fix-host-case-escaped-prefix

Conversation

@umputun

@umputun umputun commented Oct 31, 2026

Copy link
Copy Markdown
Owner

more host and path spellings that could skip the auth or IP restriction of a narrower rule, found in a sweep after #269.

  • host case: exact host lookup was case-sensitive, so ADMIN.example.com could skip an admin.example.com rule and match a broader wildcard or regex rule for the same upstream. Exact and *.example.com server names now match case-insensitively; regex servers and the host passed to $host are unchanged
  • trailing dot: admin.example.com and admin.example.com. were not treated as the same host, so either spelling could miss its exact rule. Exact and *.example.com names now ignore one trailing dot on either side
  • escaped static prefixes: static routes compared the escaped request path with the plain assets root, so a protected /private docs/ route never matched /private%20docs/x and a broader route served the file. The root is now escaped before the comparison

README notes cover host matching, escaped route paths, (?i) for upstreams that ignore path case, and reading X-Forwarded-For from the right.

exact host lookup was case-sensitive, so ADMIN.example.com could skip an
admin.example.com rule with an allowlist and match a broader wildcard or
regex rule for the same upstream. A server that
equals the host ignoring case now wins before any wildcard or regex server,
and the *.example.com suffix check ignores case. Regex servers and the host
passed to $host are unchanged.

static routes compared the escaped request path with the plain assets root,
so a protected "/private docs/" route never matched /private%20docs/x and a
broader route served the file. The root is now escaped before the comparison;
file serving still uses the plain root.

README notes cover host case, escaped route paths, (?i) for case-insensitive
upstreams, and reading X-Forwarded-For from the right.
host lookup did not treat `admin.example.com` and `admin.example.com.` as
equivalent. A dotted request could lose exact-rule precedence to another
regex, while a dotted config key could send the plain spelling to a
catch-all. Either could bypass the intended rule's auth or allowlist when the
broader rule reached the same backend. Exact and *.example.com server names
now ignore one trailing dot on either side. Regex servers are unchanged.
Copilot AI balanced review requested due to automatic review settings October 31, 2026 07:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@umputun
umputun merged commit 34372ae into master Oct 31, 2026
5 checks passed
@umputun
umputun deleted the fix-host-case-escaped-prefix branch October 31, 2026 07:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants